package cn.glutnn.controller;


import cn.glutnn.entity.Finance;
import cn.glutnn.entity.FinancingIntention;
import cn.glutnn.entity.Result;
import cn.glutnn.service.FinanceService;
import cn.glutnn.service.FinancingIntentionService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * (Finance)表控制层
 *
 * @author makejava
 * @since 2024-10-30 11:22:52
 */
@RestController
@Tag(name = "融资管理接口和银行智能匹配模块接口")
@RequestMapping("/finance")
public class FinanceController {
    /**
     * 服务对象
     */
    @Autowired
    private FinanceService financeService;

    @Autowired
    private FinancingIntentionService financingIntentionService;


    // //分页查询推荐融资人
    @Operation(summary = "分页查询推荐融资人")
    @GetMapping("/selectRecommend/{pageNum}/{pageSize}")
    public Result<IPage<FinancingIntention>> selectRecommend(@PathVariable(value = "pageNum") Integer pageNum, @PathVariable("pageSize") Integer pageSize){
        return financingIntentionService.selectRecommend(pageNum,pageSize);
    }

    //根据id修改融资情报
    @Operation(summary = "根据id修改融资情报")
    @PutMapping("/update")
    public Result updateFinancingIntentionById(@RequestBody Finance finance){
        return Result.success(financeService.editById(finance));
    }

    ////根据id查询融资情报

    @Operation(summary = "根据id查询融资情报")
    @GetMapping("/selectById/{financeId}")
    public Result<Finance> selectById(@PathVariable("financeId") Integer financeId){
        return financeService.selectByFinanceId(financeId);
    }


    //根据银行id与申请人查询融资情报

    @Operation(summary = "根据银行id与申请人查询融资情报")
    @GetMapping("/selectByBankIdAndUserName/{realName}/{pageNum}")
    public Result<Page<Finance>> selectByBankIdAndUserName( @PathVariable("realName") String realName,
                                                           @PathVariable("pageNum") Integer pageNum){
        return financeService.selectByBankIdAndUserName(realName,pageNum);
    }


    //根据银行id查询融资情报并分页

    @Operation(summary = "根据银行id查询融资情报并分页")
    @GetMapping("/selectByBankId/{pageNum}/{pageSize}")
    public Result<Page<Finance>> selectByBankId(
                                                @PathVariable("pageNum")Integer pageNum,
                                                @PathVariable("pageSize") Integer pageSize
                                                ){
        return financeService.selectByBankId(pageNum,pageSize);
    }

}

